<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
	</head>
	<body>
		<div>
			<input class="num" type="text" />
			<button class="btn">计算</button>
			<div class="result"></div>
			<div class="count"></div>
		</div>
		
	</body>
	<script type="text/javascript" src="jquery-2.1.0.js"></script>
	<script type="text/javascript">
		$(".btn").click(function(){			
			var n = 0;
			var timer = setInterval(function(){
				n++
				$(".count").text(n)
			},1000)
			
			var value = $(".num").val()
			var w = new Worker('./webWorker.js');
			w.postMessage(value);
			w.onmessage = function(e){
				$(".result").text(e.data)
				clearInterval(timer)
			}
		})
		
		
	</script>
</html>
